import {defHttp} from '/@/utils/http/axios';
import {Modal} from 'ant-design-vue';

enum Api {
  page = '/infra-service/mpAutoReply/pageMpAutoReply',
  save = '/infra-service/mpAutoReply/saveMpAutoReply',
  edit = '/infra-service/mpAutoReply/updateMpAutoReply',
  delete = '/infra-service/mpAutoReply/deleteMpAutoReply',
  deleteBatch = '/infra-service/mpAutoReply/batchDeleteMpAutoReply'
}

/**
 * 列表
 * @param params
 */
export const pageMpAutoReply = (params) => defHttp.get({url: Api.page, params});

/**
 * 删除
 */
export const deleteMpAutoReply = (params, handleSuccess) => {
  return defHttp.delete({url: Api.delete, params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}
/**
 * 批量删除
 * @param params
 */
export const batchDeleteMpAutoReply = (params, handleSuccess) => {
  Modal.confirm({
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}

/**
 * 保存或者更新
 * @param params
 */
export const saveOrUpdateMpAutoReply = (params, isUpdate) => {
  let url = isUpdate ? Api.edit : Api.save;
  return defHttp.post({url: url, params});
}



